import { createRouter, createWebHashHistory } from "vue-router";
import Layout from "@/layout/index.vue";
import Login from "@/views/login/index.vue";
import ErrorPage from "@/views/404/index.vue";

const routes = [
  {
    path: "/login",
    component: Login,
  },
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/layout",
    component: Layout,
    children: [
      {
        path: "/detail",
        name: "detail",
        component: () => import("@/views/details/index.vue"),
        meta: {
          title: "概览",
        },
      },
      {
        path: "/user",
        name: "user",
        component: () => import("@/views/user/index.vue"),
        meta: {
          title: "用户管理",
        },
      },
      {
        path: "/upload",
        component: () => import("@/views/upload/index.vue"),
        meta: {
          title: "上传内容管理",
        },
      },
      {
        path: "/pe",
        component: () => import("@/views/PE/index.vue"),
        meta: {
          title: "PE工程管理",
        },
      },
      {
        path: "/rag",
        component: () => import("@/views/RAG/index.vue"),
        meta: {
          title: "全局RAG管理",
        },
      },
      {
        path: "/variable",
        component: () => import("@/views/variabales/index.vue"),
        meta: {
          title: "变量表",
        },
      },
    ],
  },
  {
    path: "/:catchAll(.*)",
    component: ErrorPage,
  },
];

const router = createRouter({
  routes,
  history: createWebHashHistory(),
});

export default router;
